import util from '../../utils/util.js'
Page({
  data: {
    category : ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    var that = this;
    wx.request({
      url : util.http +"categories/",
      data : {},
      header : {
        'content-type': 'application/json'
      },
      success : function(res){
        that.setData({
          category : res.data
        })
      }
    })
  },
  clickCategory(e){
    var id = e.currentTarget.dataset.id,
        category = e.currentTarget.dataset.category,
        link = "../cars/cars?id=" + id +"&category="+category;
    setTimeout(function(){
      wx.navigateTo({
        url: link
      })
    },600)
  }
})